package com.woniuxy.controller;

import com.woniuxy.Exception.serviceException;
import com.woniuxy.entity.Nurse;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.ResponseResult;
import com.woniuxy.entity.Working;
import com.woniuxy.service.WorkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WorkingController {
@Autowired
    WorkingService workingService;



    @PostMapping("/working/{pageIndex}/{pageSize}")
    public ResponseResult<PageBean<Working>>getAllNurse(@RequestBody Working working,
                                                        @PathVariable("pageIndex")int pageIndex,
                                                        @PathVariable("pageSize")int pageSize) {

        ResponseResult<PageBean<Working>> responseResult;
        try {
            PageBean<Working> pageBean = workingService.getAllWorking(working, pageIndex, pageSize);
            responseResult = new ResponseResult<>(200, "ok", pageBean);

            return responseResult;
        } catch (serviceException e) {
            responseResult = new ResponseResult<>(500, e.getMessage(), null);
            return responseResult;
        }
    }


@PostMapping("/working")
public void addWorking(@RequestBody Working working){

  workingService.addWorking(working);

}

 @PutMapping("/working")
 public void upWorking (@RequestBody Working working) {


        workingService.upWorking(working);
 }







}
